﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.ServiceModel.Description;
using System.IdentityModel.Selectors;
using Sinacor.Infra.Common.Security.Authentication.Credentials;

namespace Sinacor.Infra.Common.Security.Authentication.ClientCredentials
{
    public class SinacorClientCredentials : System.ServiceModel.Description.ClientCredentials
    {
        SinacorUserInfo _userInfo;

        public SinacorUserInfo UserInfo
        {
            get { return _userInfo; }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                _userInfo = value;
            }
        }

        public SinacorClientCredentials()
        {
        }

        protected SinacorClientCredentials(SinacorClientCredentials other)
            : base(other)
        {
            this.UserInfo = other.UserInfo;
        }

        public override SecurityTokenManager CreateSecurityTokenManager()
        {
            return new SinacorClientCredentialsSecurityTokenManager(this);
        }

        protected override System.ServiceModel.Description.ClientCredentials CloneCore()
        {
            return new SinacorClientCredentials(this);
        }
    }
}
